/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author USER
 */
@Entity
@Table(name = "RegisteredUser", catalog = "WebPhotoShare", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "RegisteredUser.findAll", query = "SELECT r FROM RegisteredUser r"),
    @NamedQuery(name = "RegisteredUser.findByUsername", query = "SELECT r FROM RegisteredUser r WHERE r.username = :username"),
    @NamedQuery(name = "RegisteredUser.findByPassword", query = "SELECT r FROM RegisteredUser r WHERE r.password = :password"),
    @NamedQuery(name = "RegisteredUser.findByFirstName", query = "SELECT r FROM RegisteredUser r WHERE r.firstName = :firstName"),
    @NamedQuery(name = "RegisteredUser.findByLastName", query = "SELECT r FROM RegisteredUser r WHERE r.lastName = :lastName"),
    @NamedQuery(name = "RegisteredUser.findByBirthday", query = "SELECT r FROM RegisteredUser r WHERE r.birthday = :birthday"),
    @NamedQuery(name = "RegisteredUser.findByGender", query = "SELECT r FROM RegisteredUser r WHERE r.gender = :gender"),
    @NamedQuery(name = "RegisteredUser.findByPhone", query = "SELECT r FROM RegisteredUser r WHERE r.phone = :phone"),
    @NamedQuery(name = "RegisteredUser.findByEmail", query = "SELECT r FROM RegisteredUser r WHERE r.email = :email"),
    @NamedQuery(name = "RegisteredUser.findByApproved", query = "SELECT r FROM RegisteredUser r WHERE r.approved = :approved"),
    @NamedQuery(name = "RegisteredUser.findByDateRegister", query = "SELECT r FROM RegisteredUser r WHERE r.dateRegister = :dateRegister")})
public class RegisteredUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Username", nullable = false, length = 10)
    private String username;
    @Basic(optional = false)
    @Column(name = "Password", nullable = false, length = 15)
    private String password;
    @Basic(optional = false)
    @Column(name = "FirstName", nullable = false, length = 25)
    private String firstName;
    @Basic(optional = false)
    @Column(name = "LastName", nullable = false, length = 20)
    private String lastName;
    @Basic(optional = false)
    @Column(name = "Birthday", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date birthday;
    @Basic(optional = false)
    @Column(name = "Gender", nullable = false)
    private boolean gender;
    @Basic(optional = false)
    @Lob
    @Column(name = "Address", nullable = false, length = 2147483647)
    private String address;
    @Basic(optional = false)
    @Column(name = "Phone", nullable = false, length = 14)
    private String phone;
    @Basic(optional = false)
    @Column(name = "Email", nullable = false, length = 25)
    private String email;
    @Basic(optional = false)
    @Column(name = "Approved", nullable = false)
    private boolean approved;
    @Column(name = "DateRegister")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateRegister;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "registeredUser")
    private Collection<Comment> commentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "registeredUser")
    private Collection<UserLog> userLogCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "registeredUser")
    private Collection<Photo> photoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "registeredUser")
    private Collection<JoinContest> joinContestCollection;
    @OneToMany(mappedBy = "registeredUser")
    private Collection<Category> categoryCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "registeredUser")
    private Collection<Vote> voteCollection;

    public RegisteredUser() {
    }

    public RegisteredUser(String username) {
        this.username = username;
    }

    public RegisteredUser(String username, String password, String firstName, String lastName, Date birthday, boolean gender, String address, String phone, String email, boolean approved) {
        this.username = username;
        this.password = password;
        this.firstName = firstName;
        this.lastName = lastName;
        this.birthday = birthday;
        this.gender = gender;
        this.address = address;
        this.phone = phone;
        this.email = email;
        this.approved = approved;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public boolean getGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public boolean getApproved() {
        return approved;
    }

    public void setApproved(boolean approved) {
        this.approved = approved;
    }

    public Date getDateRegister() {
        return dateRegister;
    }

    public void setDateRegister(Date dateRegister) {
        this.dateRegister = dateRegister;
    }

    public Collection<Comment> getCommentCollection() {
        return commentCollection;
    }

    public void setCommentCollection(Collection<Comment> commentCollection) {
        this.commentCollection = commentCollection;
    }

    public Collection<UserLog> getUserLogCollection() {
        return userLogCollection;
    }

    public void setUserLogCollection(Collection<UserLog> userLogCollection) {
        this.userLogCollection = userLogCollection;
    }

    public Collection<Photo> getPhotoCollection() {
        return photoCollection;
    }

    public void setPhotoCollection(Collection<Photo> photoCollection) {
        this.photoCollection = photoCollection;
    }

    public Collection<JoinContest> getJoinContestCollection() {
        return joinContestCollection;
    }

    public void setJoinContestCollection(Collection<JoinContest> joinContestCollection) {
        this.joinContestCollection = joinContestCollection;
    }

    public Collection<Category> getCategoryCollection() {
        return categoryCollection;
    }

    public void setCategoryCollection(Collection<Category> categoryCollection) {
        this.categoryCollection = categoryCollection;
    }

    public Collection<Vote> getVoteCollection() {
        return voteCollection;
    }

    public void setVoteCollection(Collection<Vote> voteCollection) {
        this.voteCollection = voteCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RegisteredUser)) {
            return false;
        }
        RegisteredUser other = (RegisteredUser) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "server.entity.RegisteredUser[username=" + username + "]";
    }

}
